import { generateId } from "@/utils/id";
import { defineStore } from "pinia";
import { reactive } from "vue";

export interface EditTarget {
    x:number,
    y:number,
    id:number
}

export const useEditTargetStore = defineStore('editTargetStore',() => {
    let targets = reactive<EditTarget[]>([])

    function createTarget({x,y}:{x:number,y:number}):EditTarget {
        return {
            x,
            y,
            id:generateId()
        }
    }
    function addTarget(target:EditTarget) {
        targets.push(target)
    }
    function removeTarget(target:EditTarget) {
        targets.splice(targets.indexOf(target),1)
    }

    return {
        targets,
        createTarget,
        addTarget,
        removeTarget,
    }
})